const models = {}

export const initModels = async () => {
  // 动态导入并初始化所有模型
  const modelFiles = ['User.js', 'Sms.js']

  for (const file of modelFiles) {
    const model = (await import(`./${file}`)).default
    models[model.name] = model
  }

  // 关联所有模型
  for (const modelName of Object.keys(models)) {
    if (typeof models[modelName].associate === 'function') {
      models[modelName].associate(models)
    }
  }
}
